fix(duplications): secret key file has old form name#9248
Open
ketanwani wants to merge 1 commit intoopengovsg:developfrom
Open
fix(duplications): secret key file has old form name#9248ketanwani wants to merge 1 commit intoopengovsg:developfrom
ketanwani wants to merge 1 commit intoopengovsg:developfrom
Conversation
After a storage mode form is duplicated, the dashboard query is invalidated and refetches. When the refetch completes, dashboardForms changes (now includes the newly created form), causing the useEffect in DupeFormWizardProvider to fire again and call reset() with a newly-generated title based on the original form name. This overwrites the form state title, so the SaveSecretKeyScreen reads the wrong title via useWatch and names the downloaded file incorrectly. Fix by guarding the reset() call so it only runs while on the Details step (i.e., before the form has been created and we've moved to the save secret key screen). Fixes opengovsg#9050 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
After a storage mode form is duplicated, the dashboard query is invalidated and refetches. When the refetch completes,
dashboardFormschanges (now includes the newly created form), causing theuseEffectinDupeFormWizardProviderto fire again and callreset()with a newly-generated title based on the original form name. This overwrites the form state title, so theSaveSecretKeyScreenreads the wrong title viauseWatchand names the downloaded secret key file incorrectly.Fixes #9050
Solution
Guard the
reset()call so it only runs while on theDetailsstep (i.e. before the form has been created and the wizard has advanced to the save secret key screen).Changes
DupeFormWizardProvider.tsx— addcurrentStep !== CreateFormFlowStates.Detailsguard to theuseEffectDupeFormWizardProvider.test.tsx— add tests covering the bug scenario and the fixTest plan
npx vitest run src/features/workspace/components/DuplicateFormModal/DupeFormWizardProvider.test.tsxoutput.mp4
🤖 Generated with Claude Code